﻿
CREATE FUNCTION [dbo].[sprintf]
	(
		@Lable varchar(8000),
		@Value0 varchar(8000)=null,
		@Value1 varchar(8000)=null,
		@Value2 varchar(8000)=null,
		@Value3 varchar(8000)=null,
		@Value4 varchar(8000)=null,
		@Value5 varchar(8000)=null,
		@Value6 varchar(8000)=null,
		@Value7 varchar(8000)=null,
		@Value8 varchar(8000)=null,
		@Value9 varchar(8000)=null,
		@Value10 varchar(8000)=null
	)
RETURNS varchar(8000)
AS
BEGIN

DECLARE @Delim char(2) SET @Delim = '%s'

IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value0,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value1,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value2,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value3,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value4,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value5,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value6,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value7,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value8,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value9,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)
IF CHARINDEX(@Delim,@Lable) > 0
	SET @Lable = dbo.GetTokenLeft(@Lable,@Delim) + ISNULL(@Value10,'(Null)') + dbo.GetTokenRight(@Lable,@Delim)

SET @Lable = REPLACE(@Lable,'\n',CHAR(10)+CHAR(13))
RETURN @Lable
END



